import java.util.Arrays;

public class MyStack {
    public int[] elam;
    public int usedSize;
    public static final int DEFAULT_CAPACITY = 5;

    public MyStack() {
        elam = new int[DEFAULT_CAPACITY];
    }
    public void push(int val){
        if(isfull()){
            elam = Arrays.copyOf(elam,elam.length*2);
        }
        elam[usedSize] = val;
        usedSize++;
    }
    public int pop(){
        if(isEmpty()){
            return -1;
        }
        int ret = elam[usedSize - 1];
        usedSize--;
        return ret;
    }
    public int peek(){
        if(isEmpty()){
            return -1;
        }
        return  elam[usedSize - 1];
    }
    private boolean isfull(){
        return elam.length == usedSize;
    }
    private boolean isEmpty(){
        return usedSize == 0;
    }
}
